package com.jxaummd.mushroom.main.user.fragment;


import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.TextView;

import com.jxaummd.mushroom.R;
import com.jxaummd.mushroom.R2;
import com.jxaummd.mushroom.core.base.fragment.BaseBottomFragment;
import com.jxaummd.mushroom.main.user.contract.UserContract;
import com.jxaummd.mushroom.main.user.presenter.UserPresenter;


import butterknife.BindView;
import de.hdodenhof.circleimageview.CircleImageView;
import eu.davidea.flexibleadapter.FlexibleAdapter;
import eu.davidea.flexibleadapter.common.FlexibleItemDecoration;
import me.yokeyword.fragmentation.ISupportFragment;

public class UserFragment extends BaseBottomFragment<UserContract.Presenter>
        implements UserContract.View {


    @BindView(R2.id.ec_rv_person_setting)
    RecyclerView mRecyclerSetting = null;

    @BindView(R2.id.ec_tv_person_nickname)
    TextView mTvNickname = null;

    @BindView(R2.id.ec_tv_person_class)
    TextView mTvClass = null;

    @BindView(R2.id.ec_civ_person_head)
    CircleImageView mCivHeadImage = null;

    public static UserFragment newInstance() {
        Bundle args = new Bundle();
        UserFragment fragment = new UserFragment();
        fragment.setArguments(args);
        return fragment;
    }


    @Override
    public void onItemSelect(int position) {

    }

    @Override
    protected UserContract.Presenter initPresenter() {
        return new UserPresenter(this);
    }

    @Override
    public Object setLayout() {
        return R.layout.user_layout;
    }

    @Override
    public void onBindView(@Nullable Bundle savedInstanceState, View rootView) {
        mPresenter.start();
        initView();
    }

    private void initView() {

    }

    @Override
    public void initRecycler(FlexibleAdapter adapter) {
        FlexibleItemDecoration mItemDecoration = new FlexibleItemDecoration(getActivity())
                .withOffset(3) // This helps when top items are removed!!
                .withDivider(R.drawable.ic_line, R.layout.user_item_single_text)
                .withBottomEdge(true);
        mRecyclerSetting.setAdapter(adapter);
        mRecyclerSetting.setLayoutManager(new LinearLayoutManager(getContext()));
        mRecyclerSetting.addItemDecoration(mItemDecoration);
    }

    @Override
    public void startFrgment(ISupportFragment fragment) {
        getMyParentFragment().start(fragment);
    }
}
